package com.qingyun.edusysteam.controller;

import com.qingyun.edusysteam.dto.LoginFormDTO;
import com.qingyun.edusysteam.dto.Result;
import com.qingyun.edusysteam.dto.UserPassWordDTO;
import com.qingyun.edusysteam.service.IUserInfoService;
import com.qingyun.edusysteam.service.IUserService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;


@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private IUserService userService;
    @Resource
    private IUserInfoService userInfoService;

    @PostMapping("/login")
    public Result login(@RequestBody LoginFormDTO loginForm, HttpSession session){
        //用户登录功能
        return userService.userLogin(loginForm,session);
    }
    @PostMapping("/logout")
    public Result logout(@RequestHeader("Authorization") String token) {
        // 调用Service处理退出逻辑
        return userService.logout(token);
    }

    @PostMapping("/updatePassword")
    public Result updatePassword(@RequestHeader("Authorization") String token,@RequestBody UserPassWordDTO userPassWordDTO){
        return userService.updatePassword(token,userPassWordDTO);
    }
}
